package process

type predefinedStateName string

func (s predefinedStateName) get() predefinedStateName {
	return s
}

//StateName the state name
type StateName interface {
	get() predefinedStateName
}

//State Names
var (
	StateNameRunnable   StateName = predefinedStateName("Runnable")
	StateNameRunning    StateName = predefinedStateName("Running")
	StateNamePending    StateName = predefinedStateName("Pending")
	StateNameCompleted  StateName = predefinedStateName("Completed")
	StateNameTerminated StateName = predefinedStateName("Terminated")
	StateNameError      StateName = predefinedStateName("Error")
)

//State the state of the process.
type State interface {
	GetCurrentNode() string
	Name() StateName
	set(name StateName, current string)
}

type state struct {
	name    StateName
	current string
}

func (s *state) GetCurrentNode() string {
	return s.current
}

func (s *state) Name() StateName {
	return s.name
}

func (s *state) set(name StateName, current string) {
	s.name = name
	s.current = current
}

//NewState return the new state of the process.
func NewState(name StateName, current string) State {
	return &state{name, current}
}
